<?php (!defined('IN_SYSTEM') || !defined('ADMIN_PRE')) && exit('Access Denied!');?>
{admintemplate header}
<div class="box">
	<div class="heading">
	<h1>添加导航</h1>
	<div class="buttons">
	<a href="{url admin.php?m=nav&f=add&navtype=$navtype}" class="fr">添加导航</a>
	{loop $navtypes $k $v}
	<a href="{url admin.php?m=nav&navtype=$k}"  {if $navtype==$k}class="current"{/if}>{$v}</a>
	{/loop}
	</div>
	</div>
	<div class="main">

	<form name="save" method="post" action="?m=nav&f=save" onsubmit="return save_link()">
	<input type="hidden" name="savetype" value="edit" />
	<input type="hidden" name="id" value="{$id}" id="id"/>
	<table width="100%" cellspacing="0" class="tb">
		<tr>
			<td colspan="4"><div id="tip"></div></td>
		</tr>
		<tr>
			<td align="right">导航名称：</td>
			<td colspan="3"><input type="text" name="name" class="input" size="50" value="{$result['name']}"/></td>
		</tr>
		<tr>
			<td width="80" align="right">导航位置：</td>
			<td width="120">
			<select name="navtype" onchange="parentnav(this,{$result['parentid']})">
			{loop $navtypes $k $v}
			<option value="{$k}" {if $result['navtype']==$k}selected{/if}>{$v}</option>
			{/loop}
			</select>
			</td>
			<td width="60"  align="right">上级导航：</td><td><select name="parentid" id="parentid">
			<option  value="0">根</option>
			{loop $parents $k $v}
			<option value="{$v['id']}" {if $result['parentid']==$v['id']}selected{/if}>{$v['name']}</option>
			{/loop}
			</select></td>
		</tr>
		<tr>
			<td align="right">导航链接：</td>
			<td colspan="3"><input type="text" name="url" class="input" size="50"  value="{$result['url']}"/></td>
		</tr>
		<tr>
			<td align="right">导航说明：</td>
			<td colspan="3"><input type="text" name="title" class="input" size="50"  value="{$result['title']}"/> <span>导航的说明会在鼠标移动到其上面时显示</span></td>
		</tr>
		<tr>
			<td align="right">打开方式：</td>
			<td colspan="3"><input type="radio" name="target"  value="1" {if $result['target']==1} checked="checked"{/if} class="checkbox" /><label> 在新窗口打开</label> <input type="radio" name="target" value="0"{if $result['target']==0} checked="checked"{/if} class="checkbox" /><label> 在本窗口打开</label>
			</td>
		</tr>
		<tr>
			<td width="80" align="right">导航权限：</td>
			<td colspan="3">
			<select name="access">
			{php $groups = $_G['userobj']->user_group();}
			<option value="0">全部</option>;
			{loop $groups $group}
			<option value="{$group['gid']}" {if $group['gid']==$result['access']}selected{/if}>{$group['groupname']}</option>
			{/loop}
			</select><span>设置哪些用户组的用户才可看到此导航</span>
			</td>
		</tr>
		<tr>
			<td align="right">显示顺序：</td>
			<td colspan="3"><input type="text" name="displayorder" class="input" size="50"  value="{$result['displayorder']}"/> <span>数值越大显示越靠后</span></td>
		</tr>
		<tr>
			<td align="right">是否启用：</td>
			<td colspan="3"><input type="radio" name="visible"  value="1"{if $result['visible']==1} checked="checked"{/if} class="checkbox" /><label >启用</label> <input type="radio" name="visible"  value="0"{if $result['visible']==0} checked="checked"{/if} class="checkbox" /><label >禁用</label>
			</td>
		</tr>
		<tr class="bg2"><td></td><td colspan="3"><input type="submit" class="button" value="保存链接" /> <input type="button" class="button" onclick="window.location.href='admin.php?m=nav'" value="取消返回" /></td></tr>
	</table>
	</form>
	<script type="text/javascript">
	function parentnav(obj,pid){
		var t=$(obj).val();
		var id=$('#id').val();
		$('#parentid').html("");
		$('#parentid').append('<option value="0" >根</option>');
		if( t > 0 ) {
			$.getJSON('admin.php?m=nav&f=getparent&navtype='+t+'&tm='+Math.random(),'',function(data){
				if(data.s==true){
					for(var i=0;i<data.d.length;i++){
						var d=data.d[i];
						if(id==d.id) continue;
						$('#parentid').append('<option value="'+d.id+'" '+(pid==d.id?'selected':'')+'>'+d.name+'</option>');
					}
				}else{
					
				}
				});
		}else{
		}
	}
	</script>
	</div>
</div>
{admintemplate footer}